package listener;

import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

public class Mylistener implements HttpSessionListener,HttpSessionAttributeListener{
	private int count = 0;
	@Override
	public void attributeAdded(HttpSessionBindingEvent e) {
		System.out.println("session属性添加:"+e.getName()+"="+e.getValue());
	}

	@Override
	public void attributeRemoved(HttpSessionBindingEvent e) {
		System.out.println("session属性移除:"+e.getName()+"="+e.getValue());
		
	}

	@Override
	public void attributeReplaced(HttpSessionBindingEvent e) {
		System.out.println("session属性改变:"+e.getName()+"="+e.getValue());
		
	}

	@Override
	public void sessionCreated(HttpSessionEvent e) {
		count++;
		System.out.println("session创建"+e.getSession().getId()+" 人数:"+count);
	}

	@Override
	public void sessionDestroyed(HttpSessionEvent e) {
		count--;
		System.out.println("session销毁"+e.getSession().getId()+" 人数:"+count);
		
	}

}
